package com.project.restaurant.common.api;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class ServiceReturn<T> {
    /**
     * 服务处理的状态码
     */
    private StateCode stateCode;
    /**
     * 服务处理完后返回的数据
     */
    private T returnData;


    public ServiceReturn(ServiceStateCode stateCode,T returnData){
        this.stateCode = stateCode;
        this.returnData = returnData;
    }
    public ServiceReturn(int code,T returnData) throws Exception {
        this.stateCode = ServiceStateCode.getServiceStateCode(code);
        this.returnData = returnData;
    }

    public ServiceStateCode getStateCode() {
        return (ServiceStateCode) stateCode;
    }

    public T getReturnData() {
        return returnData;
    }

    public void setStateCode(ServiceStateCode stateCode) {
        this.stateCode = stateCode;
    }

    public void setReturnData(T returnData) {
        this.returnData = returnData;
    }
}
